#ifndef HERM_SOCKET_WIN32_SOCKST_DEF_H
#define HERM_SOCKET_WIN32_SOCKST_DEF_H

#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#include <string>
#include "herm/export_symbols.h"

namespace herm{

typedef unsigned long MultiplexorMask;
typedef SOCKET Handle;
typedef int SockLen;

const Handle INVALID_HANDLE = INVALID_SOCKET;
const int COMPLETION = -1;
const int PENDING = 1;

namespace Private{

const int FAILED = SOCKET_ERROR;
const int HOP_FLAG_NOSIGNAL = 0; 

const int HEWOULDBLOCK = WSAEWOULDBLOCK; // HE==HERM ERROR
const int HEINPROGRESS = WSAEWOULDBLOCK;
const int HECONNRESET = WSAECONNRESET;

inline int Close(Handle s)
{
	return closesocket(s);
}

inline int GetLastError()
{
	return WSAGetLastError();
}

/**
 * @brief Get the error string by error code.
 * @param [errNo] error code.
 * @return error string.
 * @note This function don't need to think performance.
 */
std::string HERM_API GetLastStrError(int errNo);

} // end namespace Private{
} // end namespace herm{

#endif
